# -*- encoding: utf-8 -*-
"""
File Name: base_subscriber
Description:
Author : 'lirui'
date: 2024/1/25
Contact: marjey_lee@163.com
Change Activity:
2024/1/25:
"""
import ll
from ll.third_party.redis_util.redis_subscrible import RedisSubscriber
from projects.monitoring.common.config.redis import REDIS_SERVER_INFO


class BaseSubscriber:
    def __init__(
            self,
            channel,
            host=REDIS_SERVER_INFO['host'],
            port=REDIS_SERVER_INFO['port'],

    ):
        self.redis_host = host
        self.redis_port = port
        self.channel = channel
        self.recall = None
        self.subscriber_client = RedisSubscriber(host, port, channel)

    def set_recall(self, recall):
        """

        Args:
            self:
            recall:

        Returns:

        """
        self.recall = recall
        self.subscriber_client.set_recall(recall=recall)

    def subscribe(self):
        self.subscriber_client.start()

    def stop(self):
        self.subscriber_client.unsubscribe()
